package flc.ast.dialog;

import android.content.Context;
import android.graphics.Color;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.View;
import android.widget.SeekBar;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;

import flc.ast.R;
import flc.ast.bean.GuessBean;
import flc.ast.databinding.DialogSelTimeBinding;
import flc.ast.view.SwitchSeekBar;
import stark.common.basic.base.BaseSmartDialog;

public class SelTimeDialog extends BaseSmartDialog<DialogSelTimeBinding> implements View.OnClickListener {

    private GuessBean guessBean;
    private int time = 90;

    public SelTimeDialog(@NonNull Context context, GuessBean guessBean) {
        super(context);
        this.guessBean = guessBean;
    }

    @Override
    protected int getGravity() {
        return Gravity.CENTER;
    }

    @Override
    protected boolean canceledOnTouchOutside() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_sel_time;
    }

    @Override
    protected void initView(View view) {
        mDataBinding.tvDialogSelTimeTitle.setText(guessBean.getName());
        mDataBinding.tvDialogSelTimeDetail.setText(guessBean.getDetail());
        mDataBinding.sbTime.setSeekTouchListenr(new SwitchSeekBar.SeekTouchListener() {
            @Override
            public void touchTop(SeekBar seekBar) {
                time = 60;
            }

            @Override
            public void touchSecond(SeekBar seekBar) {
                time = 90;
            }

            @Override
            public void touchEnd(SeekBar seekBar) {
                time = 180;
            }
        });
        mDataBinding.ivDialogSelTimeConfirm.setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ivDialogSelTimeConfirm:
                listener.onClickConfirm(time);
                dismiss();
                break;
        }
    }

    private IListener listener;

    public void setListener(IListener listener) {
        this.listener = listener;
    }

    public interface IListener {
        void onClickConfirm(int time);
    }
}
